﻿//06.Write a program that reads the coefficients a, b and c of 
//a quadratic equation ax2+bx+c=0 and solves it (prints its real roots).

using System;

namespace QuadraticEquation
{
    class SolveEquation
    {
        static void Main()
        {
            Console.Write("Please enter the first number: ");
            int a = int.Parse (Console.ReadLine());
            Console.Write("Please enter the second number: ");
            int b = int.Parse(Console.ReadLine());
            Console.Write("Please enter the third number: ");
            int c = int.Parse(Console.ReadLine());

            double d = b * b - 4 * a * c;

            if (d > 0)
            {
                double x1 = (-b - Math.Sqrt(d)) / 2 * a;
                double x2 = (-b + Math.Sqrt(d)) / 2 * a;
                Console.WriteLine("The real roots are: {0}, {1}", x1, x2);
            }
            else if (d == 0)
            {
                double x = -b / 2 * a;
                Console.WriteLine("The real root is: {0}", x);
            }
            else
            {
                Console.WriteLine("The equation has no real roots.");
            }
        }
    }
}
